<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <table id="demo" lay-filter="demo"></table>
            <script type="text/html" id="balance">
                {{ returnFloat(d.balance)}} ¥
            </script>
            <script type="text/html" id="give">
                {{ returnFloat(d.give) }} ¥
            </script>
            <script type="text/html" id="cashback">
                {{ returnFloat(d.cashback) }} ¥
            </script>
            <script type="text/html" id="gold">
                {{ returnFloat(d.gold) }} ¥
            </script>
            <script type="text/html" id="time">
                {{ formatDateTime(d.time) }}
            </script>
        </div>
    </div>
</div>
<script src="/static/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'useradmin', 'table'], function(){
        var $ = layui.$,
                table = layui.table;

        //执行渲染
        table.render({
            elem: '#demo',
            url: "/admin/Market/spell_order_operate/spell_number/{$spell_number}",
            method: 'post',
            cols: [[
                {field: 'name', title: '用户名称'},
                {field: 'phone', title: '用户手机', width: 260},
                {field: 'openid', title: 'openid', width: 400},
//                {title: '类型', width: 100, templet: function (d){ return d.spell_number === d.order ? '开团人' : '参团人' }},
                {field: 'time', title: '加入时间', width: 160, templet: "#time"}
            ]],
            page: {
                limits: [10, 20, 30, 40, 50]
            }
        });
    });

    //php时间戳用js转换为yyyy-mm-dd
    function formatDateTime(timeStamp) {
        var date = new Date();
        date.setTime(timeStamp * 1000);
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        m = m < 10 ? ('0' + m) : m;
        var d = date.getDate();
        d = d < 10 ? ('0' + d) : d;
        var h = date.getHours();
        h = h < 10 ? ('0' + h) : h;
        var minute = date.getMinutes();
        var second = date.getSeconds();
        minute = minute < 10 ? ('0' + minute) : minute;
        second = second < 10 ? ('0' + second) : second;
        return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second;
    }

    //补零
    function returnFloat(value){
        value = Math.round(parseFloat(value)*100)/100;
        var xsd = value.toString().split(".");
        if(xsd.length == 1){
            value = value.toString()+".00";
            return value;
        }
        if(xsd.length>1){
            if(xsd[1].length<2){
                value = value.toString()+"0";
            }
            return value;
        }
    }
</script>
</body>
</html>
